<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
</head>
<title>创效激励兑现</title>
<style type="text/css">
    .layui-form-select dl{
        max-height: 150px; // 原值为300，调节高度建议为50的倍数
    }
    .layui-form-label{width: 130px;}
</style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <!-- 查询区域  -->
        <div id="query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">项目编码：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="proCode" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">项目名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="proName" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">状态：</label>
                    <div class="layui-input-inline">
                        <select id="query-form-state" name="processStatus">
                            <option value="">全部</option>
                            <option value="1">审批中</option>
                            <option value="9">审批完成</option>
                            <option value="10">审批终止</option>
                        </select>
                    </div>
                </div>
                <shiro:hasPermission name="LIST_EFFECT_PLAN_CHARGED">
                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-effectPlanCharged-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
                        </button>
                        <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-reset">
                            <i class="layui-icon layui-icon-fonts-clear  layuiadmin-button-btn"></i>重置
                        </button>
                    </div>
                </shiro:hasPermission>
            </div>
        </div>
        <!-- 按钮区域  -->
        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <shiro:hasPermission name="ADD_EFFECT_PLAN_CHARGED">
                    <button class="layui-btn layuiadmin-btn-admin " data-type="add">
                        <i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>新建
                    </button>
                </shiro:hasPermission>
                <shiro:hasPermission name="EXPORT_EFFECT_PLAN_CHARGED">
                    <button class="layui-btn layuiadmin-btn-admin " data-type="export" onclick="exportList();">
                        <i class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出
                    </button>
                </shiro:hasPermission>
            </div>
        </div>
    </div>
    <!-- 数据表单 -->
    <table id="LAY-effectPlanCharged-create-manage" lay-filter="LAY-effectPlanCharged-create-manage"></table>
</div>

<script>
    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'set', 'laydate'], function(){
        var $ = layui.$
            ,form = layui.form
            ,table = layui.table
            ,element = layui.element
            ,laydate = layui.laydate;
        //tab重新渲染宽度
        element.on('tab(component-tabs-brief)', function(obj){
            $(window).resize();
        });

        //日期
        laydate.render({
            elem: '#yjs-laydate-date'
            , range: '~'
        });

        // 正则校验
        form.verify({
            //验证汉字
            CHS: [
                /^[\u0391-\uFFE5]+$/
                ,'只能输入汉字'
            ],
            //大于0的正整数
            intNumber:[
                /^[1-9]\d*$/
                ,'请输入正确的数字'
            ]
        });

        // 表单
        table.render({
            elem: '#LAY-effectPlanCharged-create-manage'
            ,url: basePath + '/effectPlanCharged/queryDataByCondition' //请求数据接口
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'proCode', title: '项目编码', align:'center'}
                ,{field: 'proName', title: '项目名称', align:'center'}
                ,{field: 'areaCompName', title: '区域公司', align:'center'}
                ,{field: 'proStaffName', title: '项目负责人', align:'center'}
                ,{field: 'applyCompName', title: '申请公司', align:'center'}
                ,{field: 'applyDeptName', title: '申请部门', align:'center'}
                ,{field: 'applyStaffName', title: '申请人', align:'center'}
                ,{field: 'processStatus', title: '单据状态', align:'center', templet: function (d) {
                        var processStatus = '';
                        if (d.processStatus == '1') {
                            processStatus = '审批中'
                        } else if (d.processStatus == '9') {
                            processStatus = '审批完成'
                        }else if (d.processStatus == '10') {
                            processStatus = '审批终止'
                        }
                        return processStatus;
                    }}
                ,{title: '操作', width: 240, align:'center', templet: function(d){
                        var optStr ="";
                        <shiro:hasPermission name="VIEW_EFFECT_PLAN_CHARGED">
                        optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>详情</a>';
                        </shiro:hasPermission>
                        return optStr;
                    }
                }
            ]]
            ,page: true
            ,limit: 10
        });

        <shiro:hasPermission name="LIST_EFFECT_PLAN_CHARGED">
        //监听搜索
        form.on('submit(LAY-effectPlanCharged-search)', function(data){
            //执行重载
            table.reload('LAY-effectPlanCharged-create-manage', {page: {curr: 1},
                where: trimData(data)
            });
        });
        //重置清空
        form.on('submit(LAY-user-back-reset)', function(data){
            reset_form('query-form');
            //额外处理select
            if('${bindOrgId}'==null||'${bindOrgId}'==""){
                $("#query-select-orgId").val('${superOrgId}');
            }else{
                $("#query-select-orgId").val('${bindOrgId}');
            }
            form.render();
        });
        </shiro:hasPermission>

        // 监听操作列
        table.on('tool(LAY-effectPlanCharged-create-manage)', function(obj){
            var data = obj.data;
            if(obj.event === 'freeze'){
                layer.confirm('确定要作废？',{icon:3, title :'提示'}, function(index){
                    $.ajax({
                        type : 'post',
                        url : basePath + '/effectPlanCharged/updateStatus',
                        data : {
                            "id" :data.id
                        },//数据，这里使用的是Json格式进行传输
                        success:function(result){
                            if(result){
                                table.reload('LAY-effectPlanCharged-create-manage'); //数据刷新
                                layer.close(index); //关闭弹层
                            }else{
                                layer.msg('数据通信异常~',{icon: 0});
                            }
                        }
                    });
                })
            }else if(obj.event === 'view'){
                parent.layui.index.openTabsPage(basePath + '/effectPlanCharged/toDealOrDetail?id='+data.id + '&proCode=' + data.proCode,' 创效激励兑现 > 详情');
            }else if(obj.event === 'edit'){
                //parent.layui.index.openTabsPage(basePath + '/effectPlanCharged/edit?id='+data.id,' 创效激励兑现 > 修改');
            }
        });


        // 按钮事件
        var active = {
            add: function(){
                parent.layui.index.openTabsPage(basePath + '/effectPlanCharged/toDealOrDetail',' 创效激励兑现 > 新建');
            }
        }
        // data-type事件
        $('.layui-btn.layuiadmin-btn-admin').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

    //导出excel
    function exportList() {
        layer.msg("暂未上线，敬请期待~",{icon: 1});
        /*var $ = layui.$;
        var params = "?proCode=";
        params += $('#queryProCode').val().trim();
        params += "&startDate=";
        params += $('#sent-laydate-start').val().trim();
        params += "&endDate=";
        params += $('#sent-laydate-end').val().trim();
        params += "&customerName=";
        params += $('#queryCustomerName').val().trim();
        params += "&mobile=";
        params += $('#queryMobile').val().trim();
        params += "&provinceName=";
        params += $('#queryProvinceName').val().trim();
        params += "&cityName=";
        params += $('#queryCityName').val().trim();
        params += "&state=";
        params += $('#queryState').val().trim();
        window.location.href = "${ctx}/effectPlanCharged/exportToExcel"+params;*/
    }
</script>
</body>
</html>

